package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingElderDto;
import com.zzyl.dto.NursingProjectDto;
import com.zzyl.service.NursingProjectSevice;
import com.zzyl.vo.NursingProjectVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/nursing_project")
public class NursingProjectController {
    @Autowired
    private NursingProjectSevice nursingProjectSevice;
    //分页查询
    @GetMapping
    public ResponseResult<NursingProjectVo> page(
            String name,
            Integer pageNum,
            Integer pageSize,
            Integer status
    ){
        PageResponse<NursingProjectVo> responseResult=nursingProjectSevice.page(name,pageNum,pageSize,status);
       return ResponseResult.success(responseResult);

    }

    //新增员工
    @PostMapping
    public ResponseResult<NursingProjectDto> add( @RequestBody NursingProjectDto NursingProjectDto){
        nursingProjectSevice.add(NursingProjectDto);
        return ResponseResult.success();
    }

    //根据id查询
    @GetMapping("/{id}")
    public ResponseResult<NursingProjectVo> findById(@PathVariable Long id){
        NursingProjectVo nursingProjectVo=nursingProjectSevice.findById(id);
        return ResponseResult.success(nursingProjectVo);
    }

    //修改员工
    @PutMapping
    public ResponseResult<NursingProjectDto> update(@RequestBody NursingProjectDto nursingProjectDto){
        nursingProjectSevice.update(nursingProjectDto);
        return ResponseResult.success();
    }

    //启动禁用
    @PutMapping("/{id}/status/{status}")
    public ResponseResult<NursingProjectDto> status( @PathVariable Long id, @PathVariable Integer status){
        nursingProjectSevice.status(id,status);
        return ResponseResult.success();
    }
    //删除
    @DeleteMapping("/{id}")
    public ResponseResult<NursingProjectDto> deleteById(@PathVariable Long id){
        nursingProjectSevice.deleteById(id);
        return ResponseResult.success();
    }

    //查询所有护理项目
    @GetMapping("/all")
    public ResponseResult<List<NursingProjectVo>> findAll(){
        List<NursingProjectVo> nursingProjectVo=nursingProjectSevice.findAll();
        return ResponseResult.success(nursingProjectVo);
    }

}
